package com.hxd.mall.module.usercenter.funs

import com.hxd.mall.network.base.BaseRequest
import com.hxd.mall.network.service.IMeFunctionApi
import com.hxd.mall.network.service.ManagerFunctionApi.mIMeFunctionApi
import com.hxd.mall.utils.open.ToastUtil
import javax.inject.Inject

/**
 * @author zhaoyong
 * @description:
 * @date :2019/7/17 11:08 AM
 */
class FunsManagerPresenter @Inject constructor(view: IFunsManagerView) : IFunsManagerPresenter {

    private var mView: IFunsManagerView = view
    private var mMainFunctionApi: IMeFunctionApi? = null

    constructor(view: IFunsManagerView, mainFunctionApi: IMeFunctionApi) : this(view) {
        this.mView = view
        this.mMainFunctionApi = mainFunctionApi
    }

    override fun getData(isRefresh: Boolean) {
    }

    override fun getData(pageNum :Int,pageSize:Int?) {
        BaseRequest.request(mIMeFunctionApi.queryFuns(pageNum,pageSize), mView,{
            mView.finishRefresh()
            mView.showData(it)
        }, {
            ToastUtil.showToast(it.msg ?: "")
            mView.finishFailRefresh()
        })

    }

    override fun getVersionInfo() {
        /*BaseRequest.request(mMainFunctionApi!!.versionInfo, {
            mView.showData(it)
        }, {
            Logger.i("request fail")
        }, false)*/
    }
}